package IMIC.NGUYENVANTINH.ARRAY.EXCERCISE.EX01;

import java.util.Scanner;

public class Views {
	public static void main(String[] args) {
		boolean flag = false;
		// khai bao scanner de nguoi dung nhap vao tu ban phim
		int k = 0;
		int icount = 0;
		int[] temp = new int[100];
		int[] myarr;
		Scanner sc = new Scanner(System.in);
		int n = 0;
		do {
			System.out.println("Nhap danh sach cac phan tu (Nhap gia tri am de ket thuc)");
			n = sc.nextInt();
			if (n > 0) {
				temp[icount] = n;
				icount++;
			}
			k++;
		} while (n >= 0 && k < temp.length);
		myarr = new int[icount];
		System.arraycopy(temp, 0, myarr, 0, icount);
		Controllers ctrl = new Controllers();
		System.out.println("Mang vua nhap la");
		Print(myarr);
		int[] Array1 = ctrl.IndexArray(myarr, 0);
		System.out.println("Co " + Array1.length + " diem tren trung binh");
		System.out.println("Cac diem tren trung binh la");
		Print(Array1);
		
		int[] Array2 = ctrl.IndexArray(myarr, 1);
		System.out.println("Co " + Array2.length + " diem duoi trung binh");
		System.out.println("Diem duoi trung binh la:");
		Print(Array2);
	}

	static void Print(int[] myarr) {
		for (int i = 0; i < myarr.length; i++) {
			System.out.print(myarr[i] + " ");
		}
		System.out.println("");

	}

}
